package com.yzh.pethome.service.impl;

import com.yzh.pethome.domain.PageList;
import com.yzh.pethome.domain.PageParams;
import com.yzh.pethome.mapper.DeptMapper;
import com.yzh.pethome.pojo.Dept;
import com.yzh.pethome.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;
    @Override
    public List<Dept> selectAllDept() {
        return deptMapper.selectAllDept();
    }
    @Override
    public void addDept(Dept dept) {
        deptMapper.addDept(dept);
    }
    @Override
    public void deleteDept(Long id) {
        deptMapper.deleteDept(id);
    }
    @Override
    public void updateDept(Dept dept) {
        deptMapper.updateDept(dept);
    }
    @Override
    public Dept selectDeptById(Long id) {
        return deptMapper.selectDeptById(id);
    }
    @Override
    public PageList<Dept> selectDeptByPage(PageParams pageParams) {
        PageList<Dept> pageList = new PageList<>();
        pageList.setPageNum(pageParams.getPageNum());
        pageList.setPageSize(pageParams.getPageSize());
        pageList.setTotalCount(deptMapper.selectDeptCount());
        List<Dept>list=deptMapper.selectDeptByPage(pageParams);
        pageList.setDeptlist(list);

         return pageList;
    }

}
